<template>
  <div>
    <h1>添加用户功能</h1>

    <table>
      <tr>
        <td>账号</td>
        <td>
          <input type="text" v-model="loginInfo.UserName" >
        </td>
      </tr>
      <tr>
        <td>密码</td>
        <td>
          <input type="password" v-model="loginInfo.UserPwd" >
        </td>
      </tr>
      <tr>
        <td></td>
        <td>
          <input type="button" value="添加" @click="addlogin" >
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">

import router from '@/router';
import axios from 'axios';
    import {reactive,toRefs} from 'vue'

    let data:any=reactive({
      loginInfo:{
        UserName:'',
        UserPwd:''
      }
    })

    let {loginInfo} =toRefs(data);


    const addlogin=()=>{
      alert('用户添加成功');
      router.push('/newshow');

      axios({
        url:'/api/User/PostLoginAdd',
        method:'post',
        data:loginInfo.value
      }).then(res=>{
        if (res.data>0) {
          alert('用户添加成功');
        }
        else
        {
          alert('用户添加失败');
        }

      }).catch(err=>{

      })
    }



</script>

<style scoped>

</style>